package com.ricchieri.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.ricchieri.dao.interf.ICharterExpenseDao;
import com.ricchieri.filter.CharterExpenseFilter;
import com.ricchieri.model.CharterExpense;
import com.ricchieri.service.interf.ICharterExpenseService;

@Transactional(readOnly = true)
public class CharterExpenseService implements ICharterExpenseService, Serializable {
	private static final long serialVersionUID = -2141276597707083953L;
	ICharterExpenseDao charterExpenseDao;
	
	@Override
	@Transactional(readOnly = true)
	public List<CharterExpense> getAllCharterExpense() {
		CharterExpenseFilter filter = new CharterExpenseFilter();
		return charterExpenseDao.getAllCharterExpense(filter);
	}
	
	@Transactional(readOnly = false)
	public void addCharterExpense(CharterExpense charter){
		charterExpenseDao.add(charter);
	}
	
	@Transactional(readOnly = false)
	public void deleteCharterExpense(CharterExpense charter) {
		charter.setActive(Boolean.FALSE);
		charterExpenseDao.update(charter);
	}

	@Override
	public List<CharterExpense> getAllCharterExpensePaginatedByFilter(
			CharterExpenseFilter charterFilter, int startRecord) {
		return charterExpenseDao.getAllCharterExpensePaginatedByFilter(charterFilter, startRecord);
	}

	@Override
	public int getAllCharterExpenseCountByFilter(CharterExpenseFilter charterFilter) {
		return charterExpenseDao.getAllCharterExpenseCountByFilter(charterFilter);
	}

	@Override
	@Transactional(readOnly = false)
	public void updateCharterExpense(CharterExpense charter) {
		charterExpenseDao.update(charter);
	}

	public ICharterExpenseDao getCharterExpenseDao() {
		return charterExpenseDao;
	}

	public void setCharterExpenseDao(ICharterExpenseDao charterExpenseDao) {
		this.charterExpenseDao = charterExpenseDao;
	}
}
